home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / gui / mui / mui14-dv.lha / MUI / Developer / Modula / txt / MuiMacros.def < prev    next >
Encoding:
Modula Definition  |  1993-10-27  |  11.4 KB  |  386 lines

  1. DEFINITION MODULE MuiMacros;
  2.  
  3. (****************************************************************************
  4. **
  5. **      MUI Macros
  6. **
  7. **      Converted to Modula by Christian "Kochtopf" Scholz
  8. **
  9. **      refer also to MuiMacros.mod if you want to know, how they are made.
  10. **
  11. **      Version : 26.10.1993
  12. **
  13. ****************************************************************************
  14. ** Class Tree
  15. ****************************************************************************
  16. **
  17. ** rootclass               (BOOPSI's base class)
  18. ** +--Notify               (implements notification mechanism)
  19. **    +--Application       (main class for all applications)
  20. **    +--Window            (handles intuition window related topics)
  21. **    +--Area              (base class for all GUI elements)
  22. **       +--Rectangle      (creates empty rectangles)
  23. **       +--Image          (creates images)
  24. **       +--Text           (creates some text)
  25. **       +--String         (creates a string gadget)
  26. **       +--Prop           (creates a proportional gadget)
  27. **       +--Gauge          (creates a fule gauge)
  28. **       +--Scale          (creates a percentage scale)
  29. **       +--Boopsi         (interface to BOOPSI gadgets)
  30. **       +--Colorfield     (creates a field with changeable color)
  31. **       +--List           (creates a line-oriented list)
  32. **       !  +--Floattext   (special list with floating text)
  33. **       !  +--Volumelist  (special list with volumes)
  34. **       !  +--Scrmodelist (special list with screen modes)
  35. **       !  \--Dirlist     (special list with files)
  36. **       +--Group          (groups other GUI elements)
  37. **          +--Virtgroup   (handles virtual groups)
  38. **          +--Scrollgroup (handles virtual groups with scrollers)
  39. **          +--Scrollbar   (creates a scrollbar)
  40. **          +--Listview    (creates a listview)
  41. **          +--Radio       (creates radio buttons)
  42. **          +--Cycle       (creates cycle gadgets)
  43. **          +--Slider      (creates slider gadgets)
  44. **          +--Coloradjust (creates some RGB sliders)
  45. **          \--Palette     (creates a complete palette gadget)
  46. **
  47. ****************************************************************************)
  48.  
  49. IMPORT  MD:MuiD;
  50. IMPORT  ML:MuiL;
  51. IMPORT  UD:UtilityD;
  52. FROM    UtilityD IMPORT HookPtr;
  53. FROM    SYSTEM IMPORT ADDRESS, ADR, TAG;
  54.  
  55. TYPE    APTR    = ADDRESS;      (* just for readability *)
  56.         StrPtr  = ADDRESS;
  57.  
  58.         ShortString = ARRAY[0..3] OF CHAR;  (* for MakeID *)
  59.  
  60.         (* Here some Types you have to use, IF you want to fill the
  61.            array, the ListDisplayHook gets as parameter and which the hook
  62.            has to fill *)
  63.  
  64.         STRING      = ARRAY[0..255] OF CHAR;
  65.         STRPTR      = POINTER TO STRING;
  66.         STRARR      = ARRAY[0..10] OF STRPTR; (* set 10 to the number of columns you have in your list *)
  67.         STRARRPTR   = POINTER TO STRARR;
  68.  
  69.         (* Use it the following way :
  70.  
  71.         Your Hookfunction :
  72.  
  73.         PROCEDURE dspfunc(hook : HookPtr; array : APTR; entry : APTR) : APTR;
  74.  
  75.             BEGIN
  76.                 CAST(STRARRPTR,array)^[0]:=ADR(first string);
  77.                 CAST(STRARRPTR,array)^[1]:=ADR(second string);
  78.                 ...
  79.                 RETURN 0;
  80.             END dspfunc;
  81.         
  82.         As you see, it is the same as string-arrays in C  *)
  83.  
  84.  
  85.         (* Here your PROCEDURE-Prototype for your hookfunction : *)
  86.         
  87.         HookDef     = PROCEDURE(HookPtr, APTR, APTR):APTR;
  88.  
  89. (*
  90. **  MUI - Object Generation
  91. **
  92. **  These Macros are equal to the C-Macros which can be found in mui.h
  93. **  But notice, that you have a different usage of these :
  94. **
  95. **  Instead of
  96. **
  97. **      app = ApplicationObject,
  98. **
  99. **              ...
  100. **
  101. **            End;
  102. **
  103. **  you now write :
  104. **
  105. **      app := ApplicationObject(TAG(buffer,    (* TAG from SYSTEM *)
  106. **
  107. **              ...
  108. **
  109. **             tagEnd));    (* tagEnd imported from UtilityD *)
  110. **
  111. **  Also you can't use :
  112. **
  113. **      app := ApplicationObject(TAG(buffer,
  114. **
  115. **              ...
  116. **  ====>            window:=WindowObject(TAG(buffer, ... , tagEnd)),
  117. **              ...
  118. **
  119. **             tagEnd));
  120. **
  121. **  instead of this, you have to define your Window-Object before the
  122. **  Application-Object and then use the pointer in the App-Definition :
  123. **
  124. **      window := WindowObject(TAG(buffer, ... , tagEnd)),
  125. **
  126. **      app := ApplicationObject(TAG(buffer,
  127. **
  128. **              ...
  129. **                   window,
  130. **              ...
  131. **
  132. **             tagEnd));
  133. **
  134. **  So you can't define a whole application with one command if you need
  135. **  the pointer of some objects later on (for a Notify, etc.)
  136. **
  137. *)
  138.  
  139. CONST   Child           = MD.maGroupChild;
  140.         SubWindow       = MD.maApplicationWindow;
  141.         WindowContents  = MD.maWindowRootObject;
  142.  
  143. PROCEDURE WindowObject(tags : UD.TagItemPtr) : APTR;
  144. PROCEDURE ImageObject(tags : UD.TagItemPtr) : APTR;
  145. PROCEDURE ApplicationObject(tags : UD.TagItemPtr) : APTR;
  146. PROCEDURE NotifyObject(tags : UD.TagItemPtr) : APTR;
  147. PROCEDURE TextObject(tags : UD.TagItemPtr) : APTR;
  148. PROCEDURE RectangleObject(tags : UD.TagItemPtr) : APTR;
  149. PROCEDURE ListObject(tags : UD.TagItemPtr) : APTR;
  150. PROCEDURE PropObject(tags : UD.TagItemPtr) : APTR;
  151. PROCEDURE StringObject(tags : UD.TagItemPtr) : APTR;
  152. PROCEDURE ScrollbarObject(tags : UD.TagItemPtr) : APTR;
  153. PROCEDURE ListviewObject(tags : UD.TagItemPtr) : APTR;
  154. PROCEDURE RadioObject(tags : UD.TagItemPtr) : APTR;
  155. PROCEDURE VolumelistObject(tags : UD.TagItemPtr) : APTR;
  156. PROCEDURE FloattextObject(tags : UD.TagItemPtr) : APTR;
  157. PROCEDURE DirListObject(tags : UD.TagItemPtr) : APTR;
  158. PROCEDURE SliderObject(tags : UD.TagItemPtr) : APTR;
  159. PROCEDURE CycleObject(tags : UD.TagItemPtr) : APTR;
  160. PROCEDURE GaugeObject(tags : UD.TagItemPtr) : APTR;
  161. PROCEDURE BoopsiObject(tags : UD.TagItemPtr) : APTR;
  162. PROCEDURE ScaleObject(tags : UD.TagItemPtr) : APTR;
  163. PROCEDURE GroupObject(tags : UD.TagItemPtr) : APTR;
  164. PROCEDURE VGroup(tags : UD.TagItemPtr) : APTR;
  165. PROCEDURE HGroup(tags : UD.TagItemPtr) : APTR;
  166. PROCEDURE ColGroup(cols : LONGCARD; tags : UD.TagItemPtr) : APTR;
  167. PROCEDURE RowGroup(rows : LONGCARD; tags : UD.TagItemPtr) : APTR;
  168. PROCEDURE PageGroup(tags : UD.TagItemPtr) : APTR;
  169. PROCEDURE ColorfieldObject(tags : UD.TagItemPtr) : APTR;
  170. PROCEDURE ColoradjustObject(tags : UD.TagItemPtr) : APTR;
  171. PROCEDURE PaletteObject(tags : UD.TagItemPtr) : APTR;
  172. PROCEDURE VirtgroupObject(tags : UD.TagItemPtr) : APTR;
  173. PROCEDURE ScrollgroupObject(tags : UD.TagItemPtr) : APTR;
  174. PROCEDURE VGroupV(tags : UD.TagItemPtr) : APTR;
  175. PROCEDURE HGroupV(tags : UD.TagItemPtr) : APTR;
  176. PROCEDURE ColGroupV(cols : LONGCARD; tags : UD.TagItemPtr) : APTR;
  177. PROCEDURE RowGroupV(rows : LONGCARD; tags : UD.TagItemPtr) : APTR;
  178. PROCEDURE PageGroupV(tags : UD.TagItemPtr) : APTR;
  179.  
  180.  
  181. (*
  182. **  MakeID
  183. **  Generate an ID out of a 4-char-string.
  184. **  Use it the as WindowID ! (look in MuiTest for an example!)
  185. *)
  186.  
  187. PROCEDURE MakeID (name : ShortString): LONGINT;
  188.  
  189. (*
  190. **
  191. **  Hook Macros
  192. **
  193. **  Use it the following way :
  194. **      1. Write your Hook-Function :
  195. **          PROCEDURE hookfunc(hook:HookPtr; obj : APTR; args : APTR) : APTR
  196. **              BEGIN
  197. **              ...
  198. **              END hookfunc;
  199. **          Note, that your function needs not to specify registers, but
  200. **          your PROCEDURE must be looking like name(HookPtr, APTR, APTR)!!
  201. **
  202. **      2. Define in your VAR-section a pointer to a Hookrecord :
  203. **          VAR hook    : UtilitiesD.HookPtr;
  204. **
  205. **      3. fill it with MakeHook :
  206. **          MakeHook(hookfunc,hook);
  207. **
  208. **      4. Use it with MUI, as you like, e.g. :
  209. **          DoMethod(button,TAG(buffer,MD.mmCallHook,hook,arg1,arg2));
  210. **
  211. *)
  212.  
  213. PROCEDURE MakeHook(entry:HookDef; VAR hook : HookPtr);
  214.  
  215. (*
  216. **
  217. **  Spacing Macros
  218. **
  219. **  (not all from mui.h)
  220. **
  221. *)
  222.  
  223. PROCEDURE HVSpace() : APTR;
  224. PROCEDURE HSpace(x : LONGCARD) : APTR;
  225. PROCEDURE VSpace(x : LONGCARD) : APTR;
  226.  
  227. (*
  228. **
  229. **  Popup-Object
  230. **
  231. **
  232. *)
  233.  
  234. PROCEDURE Popup (object : APTR; 
  235.                  hook : HookPtr; 
  236.              VAR imageObj : APTR;
  237.                  imgSpec : ADDRESS) : APTR;
  238.  
  239.  
  240. (*
  241. **
  242. ** String-Object
  243. **
  244. ** Creates a simple String-Gadget
  245. **
  246. *)
  247.  
  248. PROCEDURE String(contents : ARRAY OF CHAR; maxlen : LONGINT) : APTR;
  249. PROCEDURE KeyString(contents : ARRAY OF CHAR; maxlen : LONGINT; key : CHAR) : APTR;
  250.  
  251. (*
  252. **
  253. ** Checkmark
  254. **
  255. ** creates a Checkmark Gadget
  256. **
  257. *)
  258.  
  259. PROCEDURE Checkmark(selected : BOOLEAN) : APTR;
  260. PROCEDURE KeyCheckmark(selected : BOOLEAN; key : CHAR) : APTR;
  261.  
  262. (*
  263. **
  264. ** Buttons
  265. **
  266. ** Here the same note : Use small letters for Keybuttons!
  267. **
  268. *)
  269.  
  270. PROCEDURE Simplebutton(name : ARRAY OF CHAR) : APTR;
  271. PROCEDURE Keybutton(name : ARRAY OF CHAR; key : CHAR) : APTR;
  272.  
  273. (*
  274. **
  275. **  Radio Object
  276. **
  277. *)
  278.  
  279. PROCEDURE Radio(name : ARRAY OF CHAR; array : APTR) : APTR;
  280.  
  281. (*
  282. **
  283. ** Label Objects
  284. **
  285. ** The same as in mui.h
  286. **
  287. ** Label()  : create a Label for Objects without a frame
  288. ** Label1() : create a label for Objects with a standard frame (Checkmarks...)
  289. ** Label2() : create a label for Objects with double high frame (String Gadgets...)
  290. **
  291. *)
  292.  
  293. PROCEDURE Label(label : ARRAY OF CHAR) : APTR;
  294. PROCEDURE Label1(label : ARRAY OF CHAR) : APTR;
  295. PROCEDURE Label2(label : ARRAY OF CHAR) : APTR;
  296. PROCEDURE KeyLabel(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  297. PROCEDURE KeyLabel1(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  298. PROCEDURE KeyLabel2(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  299.  
  300. (*
  301. **
  302. ** Controlling Objects
  303. **
  304. ** Again the same as in mui.h :
  305. **
  306. ** set : set an attribute of an object
  307. ** get : get an attribute of an object
  308. **       didn't work in previous releases :-( (but now!! :-)
  309. **
  310. *)
  311.  
  312. PROCEDURE get(obj : APTR; attr : LONGCARD; store : ADDRESS);
  313. PROCEDURE set(obj : APTR; attr : LONGCARD; value : LONGINT);
  314. PROCEDURE setmutex(obj : APTR; n : LONGINT);
  315. PROCEDURE setcycle(obj : APTR; n : LONGINT);
  316. PROCEDURE setstring(obj : APTR; s : ARRAY OF CHAR);
  317. PROCEDURE setcheckmark(obj : APTR; b : BOOLEAN);
  318. PROCEDURE setslider(obj : APTR; l : LONGINT);
  319.  
  320. (*
  321. ** Now some macros which are not part of mui.h (in other words : my own ;-)
  322. **
  323. ** First : NoteClose (app,obj,ID)
  324. **         ----------------------
  325. **         This macro sets up a notification on the close-gadget of a window
  326. **         if it gets pressed, the app-obj gets back an ID
  327. **         app : the application-object, which will receive the ID
  328. **         obj : the window-object
  329. **         ID  : the ID, which will be send to the app-obj, when the user
  330. **               presses the close-gadget of the window-object specified in
  331. **               obj.
  332. *)
  333.  
  334. PROCEDURE NoteClose(app : APTR; 
  335.                     obj : APTR; 
  336.                     ID  : LONGINT);
  337.  
  338. (*
  339. **  Notebutton (app,obj,ID)
  340. **  -----------------------
  341. **  Sets up a notification on a button. If it gets pressed, the app-obj
  342. **  receives an ID.
  343. **  app : the app-obj, which will receive the ID.
  344. **  obj : the pointer to the Button-Object (created by Keybutton, etc.)
  345. **  ID  : The ID, which will be send to the app-obj.
  346. **
  347. *)
  348.  
  349. PROCEDURE NoteButton(app : APTR;
  350.                      obj : APTR; 
  351.                      ID  : LONGINT);
  352.  
  353. (*
  354. ** RemMember (obj,member)
  355. ** ----------------------
  356. ** The following macro deletes a member from an object
  357. **
  358. ** obj      : The object which holds the child to remove
  359. ** member   : The child which shall be removed
  360. ** ATTENTION: You have to dispose the removed child-objects yourself!
  361. **
  362. *)
  363.  
  364. PROCEDURE RemMember(obj : APTR; member : APTR);
  365.  
  366. (*
  367. ** AddMember (obj,member)
  368. ** ----------------------
  369. ** This macro will add a new child to an group-  or application-object
  370. **
  371. ** obj      : The group or application to which the new object will be added
  372. ** member   : The new child-object which shall be added to obj.
  373. **
  374. *)
  375.  
  376. PROCEDURE AddMember(obj : APTR; member : APTR);
  377.  
  378. END MuiMacros.
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.